<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>变量作用域</title>
  </head>
  <body>
    <script>
      var a = "你好,我是全局变量的a";
      function father() {
        var b = "你好,我是father中的b";
        console.log("father中执行的语句:", a);
        console.log("father中执行的语句:", b);
        // console.log('father中执行的语句:',c);   //无法访问c属性
        function son() {
          var c = "你好,我是son中的c";
          console.log("son中执行的语句:", a);
          console.log("son中执行的语句:", b);
          console.log("son中执行的语句:", c);
        }
        son();
      }

      father();
      //   son();    //无法访问son函数
    </script>
  </body>
</html>
